﻿//********************************************************************************//
//创建日期：<创建日期，2016-10-20>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：账务查询
//********************************************************************************//

using System;
using System.Data;
using BLL;
using BLL.Access;
using DevExpress.Web;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.ChaXunGL
{
    public partial class ZhangWuCX : BasePage
    {
        protected void gvGrid2tab6_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
        }

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width)
        {
            var c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            gv.Columns.Add(c);
        }

        private void LoadColumnDate(ASPxGridView gv, string fieldName, string caption, int width, string format)
        {
            var c = new GridViewDataTextColumn();
            c.FieldName = fieldName;
            c.Caption = caption;
            c.Width = width;
            c.PropertiesEdit.DisplayFormatString = format;
            gv.Columns.Add(c);
        }


        protected void btnExport_Click(object sender, EventArgs e)
        {
            var index = ASPxPageControl1.ActiveTabIndex;
            var sName = "";
            if (index == 0)
            {
                gvGridTab1.DataSource = dtGridTab1;
                gvGridTab1.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGridTab1";
                sName = "本期信息";
                gvGridTab1.Settings.ShowFooter = false;
            }
            else if (index == 1)
            {
                gvGridTab2.DataSource = dtGridTab2;
                gvGridTab2.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGridTab2";
                sName = "本月到账";
                gvGridTab2.Settings.ShowFooter = false;
            }
            else if (index == 2)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridtab3";
                sName = "退票";
                gvGridtab3.Settings.ShowFooter = false;
            }
            else if (index == 3)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridtab4";
                sName = "退款";
                gvGridtab4.Settings.ShowFooter = false;
            }
            else if (index == 4)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridtab6";
                sName = "多收";
                gvGridtab6.Settings.ShowFooter = false;
            }
            else if (index == 5)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridtab8";
                sName = "水资源费";
                gvGridtab8.Settings.ShowFooter = false;
            }
            else if (index == 6)
            {
                ASPxGridViewExporter1.GridViewID = "gvGridtab9";
                sName = "补收";
                gvGridtab9.Settings.ShowFooter = false;
            }


            ASPxGridViewExporter1.WriteXlsToResponse(sName);
        }

        #region 属性

        /// <summary>
        ///     保存结果集1
        /// </summary>
        private DataTable dtGridTab1
        {
            get { return ViewState["dtGridTab1"] as DataTable; }
            set { ViewState["dtGridTab1"] = value; }
        }

        /// <summary>
        ///     保存结果集2
        /// </summary>
        private DataTable dtGridTab2
        {
            get { return ViewState["dtGridTab2"] as DataTable; }
            set { ViewState["dtGridTab2"] = value; }
        }

        /// <summary>
        ///     保存结果集3
        /// </summary>
        private DataTable dtGridtab3
        {
            get { return ViewState["dtGridtab3"] as DataTable; }
            set { ViewState["dtGridtab3"] = value; }
        }

        /// <summary>
        ///     保存结果集4
        /// </summary>
        private DataTable dtGridtab4
        {
            get { return ViewState["dtGridtab4"] as DataTable; }
            set { ViewState["dtGridtab4"] = value; }
        }

        /// <summary>
        ///     保存结果集5
        /// </summary>
        private DataTable dtGridtab5
        {
            get { return ViewState["dtGridtab5"] as DataTable; }
            set { ViewState["dtGridtab5"] = value; }
        }

        /// <summary>
        ///     保存结果集6
        /// </summary>
        private DataTable dtGridtab6
        {
            get { return ViewState["dtGridtab6"] as DataTable; }
            set { ViewState["dtGridtab6"] = value; }
        }

        /// <summary>
        ///     保存结果集7
        /// </summary>
        private DataTable dtGridtab7
        {
            get { return ViewState["dtGridtab7"] as DataTable; }
            set { ViewState["dtGridtab7"] = value; }
        }

        /// <summary>
        ///     保存结果集8
        /// </summary>
        private DataTable dtGridtab8
        {
            get { return ViewState["dtGridtab8"] as DataTable; }
            set { ViewState["dtGridtab8"] = value; }
        }

        /// <summary>
        ///     保存结果集9
        /// </summary>
        private DataTable dtGridtab9
        {
            get { return ViewState["dtGridtab9"] as DataTable; }
            set { ViewState["dtGridtab9"] = value; }
        }

        #endregion

        #region 变量

        /// <summary>
        ///     存储过程调用类
        /// </summary>
        private readonly SpHelper _SpHelper = new SpHelper();

        /// <summary>
        ///     行业分类
        /// </summary>
        private readonly QS_JX_HANGYEFLXXBLL HYFL = new QS_JX_HANGYEFLXXBLL();

        /// <summary>
        ///     取水用途
        /// </summary>
        private readonly QS_JX_QUSHUIXXBLL QSYT = new QS_JX_QUSHUIXXBLL();

        /// <summary>
        ///     管理部门
        /// </summary>
        private readonly QS_JX_BUMENXXBLL GLBM = new QS_JX_BUMENXXBLL();

        #endregion

        #region 事件

        /// <summary>
        ///     页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack) InitData();

            var index = ASPxPageControl1.ActiveTabIndex;


            switch (index)
            {
                case 0:
                    gvGridTab1.DataSource = dtGridTab1;
                    gvGridTab1.DataBind();
                    break;
                case 1:
                    gvGridTab2.DataSource = dtGridTab2;
                    gvGridTab2.DataBind();
                    break;
                case 2:
                    gvGridtab3.DataSource = dtGridtab3;
                    gvGridtab3.DataBind();
                    break;
                case 3:
                    gvGridtab4.DataSource = dtGridtab4;
                    gvGridtab4.DataBind();
                    break;
                //case 4:
                //    this.gvGridtab5.DataSource = this.dtGridtab5;
                //    this.gvGridtab5.DataBind();
                //    break;
                case 4:
                    gvGridtab6.DataSource = dtGridtab6;
                    gvGridtab6.DataBind();
                    break;
                //case 6:
                //    this.gvGridtab7.DataSource = this.dtGridtab7;
                //    this.gvGridtab7.DataBind();
                //    break;
                case 5:
                    gvGridtab8.DataSource = dtGridtab8;
                    gvGridtab8.DataBind();
                    break;
                case 6:
                    gvGridtab9.DataSource = dtGridtab9;
                    gvGridtab9.DataBind();
                    break;
                default: break;
            }


            if (index == 1 || index == 2 || index == 3)
            {
                cmbZhangWuY2.ClientEnabled = true;
                cmbZhangWuM2.ClientEnabled = true;
            }
        }

        /// <summary>
        ///     查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            var index = ASPxPageControl1.ActiveTabIndex;
            ActiveTabIndexChange(index);
        }

        #endregion

        #region 方法

        /// <summary>
        ///     初始化数据
        /// </summary>
        private void InitData()
        {
            var wtype = BusinessTool.WType;
            if (wtype == 1)
            {
                //int index = ASPxPageControl1.TabIndex;
                //ASPxPageControl1.tab
                //ASPxPageControl1.TabPages.Remove(2);
            }

            gvGridTab1.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvGridTab2.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvGridtab3.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvGridtab4.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            //gvGridtab7.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            PageTools.QSLoadCombox(cmbXingZhengQ, PageTools.eLoadType.行政区QS, null, "");
            //PageTools.QSLoadCombox(cmbQuShuiYT, PageTools.eLoadType.取水用途QS, null, "");
            //PageTools.QSLoadCombox(cmbHangYeLX, PageTools.eLoadType.行业分类QS, null, "");
            //PageTools.QSLoadCombox(cbmGuanLiBM, PageTools.eLoadType.管理部门QS, null, "");
            LoadQSYT();
            LoadHYFL();
            LoadGLBM();
            //账务年月
            var zwym = BusinessTool.GetSLYMorZWNY(2, wtype);
            //cmbZhangWuY2.SelectedIndex = 0;
            //cmbZhangWuM2.SelectedIndex = 0;
            cmbZhangWuY.Items.Add("全部", 0);
            for (var i = zwym / 100 - 20; i <= zwym / 100; i++)
            {
                cmbZhangWuY.Items.Add(i.ToString(), i);
                cmbZhangWuY2.Items.Add(i.ToString(), i);
            }

            cmbZhangWuY.SelectedIndex = 21;

            cmbZhangWuY2.SelectedIndex = 20;
            for (var i = 1; i < 13; i++)
            {
                cmbZhangWuM.Items.Add(i.ToString(), i);
                cmbZhangWuM2.Items.Add(i.ToString(), i);
            }

            cmbZhangWuM.SelectedIndex = zwym % 100;
            cmbZhangWuM2.SelectedIndex = zwym % 100;

            //水量年月
            // txtShuiLiangYM.Text = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();
        }

        /// <summary>
        ///     加载 取水用途
        /// </summary>
        private void LoadQSYT()
        {
            var dt = QSYT.SelectQS_JX_QUSHUIXXesDynamic("I_JLZT=0", null);
            for (var i = 0; i < dt.Rows.Count; i++)
                cmbQuShuiYT.Items.Add(dt.Rows[i]["S_QUSHUIMC"].ToString(), dt.Rows[i]["S_QUSHUIBH"]);
            cmbQuShuiYT.Items.Insert(0, new ListEditItem("", "-1"));
        }

        /// <summary>
        ///     加载行业分类
        /// </summary>
        private void LoadHYFL()
        {
            var dt = HYFL.SelectQS_JX_HANGYEFLXXesDynamic("I_JLZT=0", "S_FENLEIBH");
            for (var i = 0; i < dt.Rows.Count; i++)
                cmbHangYeLX.Items.Add(dt.Rows[i]["S_FENLEIMC"].ToString(), dt.Rows[i]["S_FENLEIBH"]);
            cmbHangYeLX.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        ///     加载管理部门
        /// </summary>
        private void LoadGLBM()
        {
            var dt = GLBM.SelectQS_JX_BUMENXXesDynamic("I_JLZT=0 and S_BUMENBH NOT IN(0,600)", null);
            for (var i = 0; i < dt.Rows.Count; i++)
                cbmGuanLiBM.Items.Add(dt.Rows[i]["S_BUMENMC"].ToString(), dt.Rows[i]["S_BUMENBH"]);
            cbmGuanLiBM.Items.Insert(0, new ListEditItem("", "0"));
        }

        /// <summary>
        ///     跟当前显示的tab也签选择查询的数据集
        /// </summary>
        /// <param name="index">当前选项卡的索引</param>
        private void ActiveTabIndexChange(int index)
        {
            var v_zwy = cmbZhangWuY.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuY.Value);
            var v_zwm = cmbZhangWuM.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuM.Value);
            var v_zwy2 = cmbZhangWuY2.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuY2.Value);
            var v_zwm2 = cmbZhangWuM2.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuM2.Value);
            var v_hnhw = cmbHuanNeiHW.Text != "" ? Convert.ToInt32(cmbHuanNeiHW.Value) : 0;
            var v_xzq = cmbXingZhengQ.Text != "" ? cmbXingZhengQ.Value.ToString() : null;
            var v_yhh = chkYongHuH.Checked && txtYongHuH.Text != "" ? txtYongHuH.Text : null;
            var v_yhm = chkYongHuM.Checked && txtYongHuM.Text != "" ? txtYongHuM.Text : null;
            var v_qsyt = rabQuShuiYT.Checked && cmbQuShuiYT.Text != "" ? cmbQuShuiYT.Value.ToString() : null;
            var v_hylx = rabHangYeLX.Checked && cmbHangYeLX.Text != "" ? cmbHangYeLX.Value.ToString() : null;
            var v_zgbm = rabGuanLiBM.Checked && cbmGuanLiBM.Text != "" ? cbmGuanLiBM.Value.ToString() : null;
            var v_ym = rabShuiLiangYM.Checked && cmbSLYM2Tab1.Text != "" && txtShuiLiangYM.Text != ""
                ? cmbSLYM2Tab1.Text + txtShuiLiangYM.Text
                : null;

            switch (index)
            {
                case 0: //本期信息
                    LoadGridDataTab1(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym);
                    break;
                case 1: //本月到账
                    LoadGridDataTab2(v_zwy, v_zwm, v_zwy2, v_zwm2, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm,
                        v_ym);
                    break;
                case 2: //退票
                    LoadGridDataTab3(v_zwy, v_zwm, v_zwy2, v_zwm2, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm,
                        v_ym);
                    break;
                case 3: //退款
                    LoadGridDataTab4(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym);
                    break;
                //case 4://欠费调整
                //    LoadGridDataTab5(); 
                //    break;
                case 4: //多收
                    LoadGridDataTab6(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym);
                    break;
                //case 6://退回灌费
                //    LoadGridDataTab7(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym);
                //    break;
                case 5: //水资源费
                    LoadGridDataTab8(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym);
                    break;
                case 6: //补收
                    LoadGridDataTab9(v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm);
                    break;
                default: break;
            }
        }

        /// <summary>
        ///     加载查询数据  本期信息
        /// </summary>
        private void LoadGridDataTab1(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var wtype = BusinessTool.WType;
            var jelx = Convert.ToInt32(cmbJinE1Tab1.Value);
            string str = null;
            string v_je = null;
            switch (jelx)
            {
                case 0:
                    str = null;
                    break;
                case 1:
                    str = " and W.KZJE";
                    break;
                case 2:
                    str = " and W.SSJE1";
                    break;
                case 3:
                    str = " and 0";
                    break;
                case 4:
                    str = " and (W.KZJE-W.SSJE1)";
                    break;
                case 5:
                    str = " and 0";
                    break;
                default: break;
            }

            if (rabJinETab1.Checked && str != "" && cmbJinE2Tab1.Text != "" && txtJinETab1.Text != "")
                v_je = str + cmbJinE2Tab1.Text + txtJinETab1.Text;


            var v_sj = rabShuiJiaTab1.Checked && cmbShuiJiaTab1.Text != "" && txtShuiJia.Text != ""
                ? cmbShuiJiaTab1.Text + txtShuiJia.Text
                : null;
            var v_qf = rabQianFeiTab1.Checked ? "1" : null;
            dtGridTab1 = _SpHelper.P_QSCX_ZWCX_BENQIXX(wtype, v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm, v_qsyt, v_hylx,
                v_zgbm, v_ym, v_je, v_sj, v_qf).Tables[0];
            gvGridTab1.DataSource = dtGridTab1;
            gvGridTab1.DataBind();
            double kzje = 0, ssje = 0, tzje = 0, qfje = 0, dsje = 0;
            long sl = 0;
            if (dtGridTab1 != null && dtGridTab1.Rows.Count > 0)
                for (var i = 0; i < dtGridTab1.Rows.Count; i++)
                {
                    kzje += dtGridTab1.Rows[i]["KZJE"].ToString() != ""
                        ? Convert.ToDouble(dtGridTab1.Rows[i]["KZJE"])
                        : 0;
                    ssje += dtGridTab1.Rows[i]["SSJE"].ToString() != ""
                        ? Convert.ToDouble(dtGridTab1.Rows[i]["SSJE"])
                        : 0;
                    tzje += dtGridTab1.Rows[i]["QFTZ"].ToString() != ""
                        ? Convert.ToDouble(dtGridTab1.Rows[i]["QFTZ"])
                        : 0;
                    qfje += dtGridTab1.Rows[i]["QF"].ToString() != "" ? Convert.ToDouble(dtGridTab1.Rows[i]["QF"]) : 0;
                    dsje += dtGridTab1.Rows[i]["DS"].ToString() != "" ? Convert.ToDouble(dtGridTab1.Rows[i]["DS"]) : 0;
                    sl += dtGridTab1.Rows[i]["KZSL"].ToString() != "" ? Convert.ToInt32(dtGridTab1.Rows[i]["KZSL"]) : 0;
                }

            lbZongYeStab1.Text = "共" + dtGridTab1.Rows.Count + "条";
            txtKaiZhangJEtab1.Text = kzje.ToString();
            txtShiShouJEtab1.Text = ssje.ToString();
            txtHeXiaoJEtab1.Text = tzje.ToString();
            txtQianFeitab1.Text = qfje.ToString();
            txtDuoShoutab1.Text = dsje.ToString();
            txtKaiZhangSLtab1.Text = sl.ToString();
        }

        /// <summary>
        ///     加载tab2页签数据 本月到帐
        /// </summary>
        private void LoadGridDataTab2(int v_zwy, int v_zwm, int v_zwy2, int v_zwm2, int v_hnhw, string v_xzq,
            string v_yhh, string v_yhm, string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var wtype = BusinessTool.WType;
            var v_je = rabJinETab2.Checked && cmbJinE2Tab2.Text != "" && txtJinETab2.Text != ""
                ? cmbJinE2Tab2.Text + txtJinETab2.Text
                : null;
            var v_dzfl = rbnDaoZhangFLtab2.Checked && cmbChaoBiaoBMtab2.Text != ""
                ? cmbChaoBiaoBMtab2.Value.ToString()
                : null;
            var v_sffs = rbnShouFeiFStab2.Checked && cmbShuiLiangYtab2.Text != ""
                ? cmbShuiLiangYtab2.Value.ToString()
                : null;
            string
                v_fylx = null; // rbnFeiYongLXtab2.Checked && cmbFeiYongLXtab2.Text != "" ? cmbFeiYongLXtab2.Value.ToString() : null;
            var v_sfdydz = 0;
            dtGridTab2 = _SpHelper.P_QSCX_ZWCX_BENYUEDZ(wtype, v_zwy, v_zwm, v_zwy2, v_zwm2, v_hnhw, v_xzq, v_yhh,
                v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym, v_je, v_dzfl, v_sffs, v_fylx, v_sfdydz).Tables[0];

            if (wtype == 2)
            {
                gvGridTab2.Columns.Clear();
                LoadColumnDate(gvGridTab2, "S_YONGHUH", "用户号", 80);
                LoadColumnDate(gvGridTab2, "S_YONGHUM", "用户名", 120);
                LoadColumnDate(gvGridTab2, "LX", "费用类型", 80);
                LoadColumnDate(gvGridTab2, "I_YM", "水量年月", 80);
                LoadColumnDate(gvGridTab2, "DZYM", "到账年月", 80);
                LoadColumnDate(gvGridTab2, "N_JINE", "到账金额", 100, "0.00");
                LoadColumnDate(gvGridTab2, "SFLX", "收费类型", 100);
                LoadColumnDate(gvGridTab2, "S_KAIHUH", "银行帐号", 120);
                LoadColumnDate(gvGridTab2, "S_KAIHUYH", "开户银行", 120);
                LoadColumnDate(gvGridTab2, "S_KAIHUHM", "开户户名", 120);
                LoadColumnDate(gvGridTab2, "USERNAME", "业务员", 80);
                LoadColumnDate(gvGridTab2, "USERNAME2", "操作员", 80);
                LoadColumnDate(gvGridTab2, "D_CAOZUORQ", "操作日期", 85, "yyyy-MM-dd");
                LoadColumnDate(gvGridTab2, "TSLX", "托收类型", 100);
                LoadColumnDate(gvGridTab2, "SL", "到账水量", 100);
                LoadColumnDate(gvGridTab2, "SZYF", "水资源费", 100, "0.00");
                LoadColumnDate(gvGridTab2, "S_ZHANGDANBH", "账单编号", 100);
                LoadColumnDate(gvGridTab2, "S_FAPIAOHM", "发票号码", 100);
            }

            gvGridTab2.DataSource = dtGridTab2;
            gvGridTab2.DataBind();
            double zje = 0;
            long sl = 0;
            double szyf = 0;
            if (dtGridTab2 != null && dtGridTab2.Rows.Count > 0)
                if (wtype == 2)
                    for (var i = 0; i < dtGridTab2.Rows.Count; i++)
                    {
                        zje += Convert.ToDouble(dtGridTab2.Rows[i]["N_JINE"]);
                        sl += Convert.ToInt32(dtGridTab2.Rows[i]["SL"]);
                        szyf += Convert.ToDouble(dtGridTab2.Rows[i]["SZYF"]);
                    }
                else
                    for (var i = 0; i < dtGridTab2.Rows.Count; i++)
                    {
                        zje += Convert.ToDouble(dtGridTab2.Rows[i]["N_JINE"]);
                        sl += Convert.ToInt32(dtGridTab2.Rows[i]["SL"]);
                    }

            lbZongYeStab2.Text = "共" + dtGridTab2.Rows.Count + "条";
            txtDaoZhangJEHZtab2.Text = zje.ToString();
            txtDaoZhangSLHZtab2.Text = sl.ToString();
            txtSZYFtab2.Text = szyf.ToString();
        }

        /// <summary>
        ///     加载tab3页签数据 退票
        /// </summary>
        private void LoadGridDataTab3(int v_zwy, int v_zwm, int v_zwy2, int v_zwm2, int v_hnhw, string v_xzq,
            string v_yhh, string v_yhm, string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var v_je = rabJinETab3.Checked && cmbJinE2Tab3.Text != "" && txtJinETab3.Text != ""
                ? cmbJinE2Tab3.Text + txtJinETab3.Text
                : null;
            var v_sg = chkSGtab3.Checked ? "0" : "1";
            dtGridtab3 = _SpHelper.P_QSCX_ZWCX_TUIPIAO(BusinessTool.WType, v_zwy, v_zwm, v_zwy2, v_zwm2, v_hnhw, v_xzq,
                v_yhh, v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym, v_je, v_sg).Tables[0];
            gvGridtab3.DataSource = dtGridtab3;
            gvGridtab3.DataBind();
            double zje = 0;
            var zsl = 0;
            double szyf = 0;
            if (dtGridtab3 != null && dtGridtab3.Rows.Count > 0)
                for (var i = 0; i < dtGridtab3.Rows.Count; i++)
                {
                    zje += Convert.ToDouble(dtGridtab3.Rows[i]["N_KAIZHANGJE"]);
                    zsl += Convert.ToInt32(dtGridtab3.Rows[i]["I_SHUILIANG"]);
                    szyf += Convert.ToDouble(dtGridtab3.Rows[i]["SZYF"]);
                }

            lbZongYeStab3.Text = "共" + dtGridtab3.Rows.Count + "条";
            txtTuiPiaoJEHZtab3.Text = zje.ToString();
            txtTuiPiaoSLHZtab3.Text = zsl.ToString();
            txtSZYFtab3.Text = szyf.ToString();
        }

        /// <summary>
        ///     加载tab4页签数据 退款
        /// </summary>
        private void LoadGridDataTab4(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var v_tkje = rbnTuiPiaoJEtab4.Checked && cbmTuiPiaoJEtab4.Text != "" && txtTuiPiaoJE2tab4.Text != ""
                ? cbmTuiPiaoJEtab4.Text + txtTuiPiaoJE2tab4.Text
                : null;
            var v_pwh = rbnPiWenHtab4.Checked && txtPiWenHtab4.Text != "" ? txtPiWenHtab4.Text : null;
            var v_tklx = rbnTuiKuanLEtab4.Checked && cbmTuiKuanLEtab4.Text != ""
                ? Convert.ToInt32(cbmTuiKuanLEtab4.Value)
                : 0;
            dtGridtab4 = _SpHelper.P_QSCX_ZWCX_TUIKUAN(BusinessTool.WType, v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm,
                v_qsyt, v_hylx, v_zgbm, v_ym, v_tkje, v_tklx, v_pwh).Tables[0];
            gvGridtab4.DataSource = dtGridtab4;
            gvGridtab4.DataBind();
            double zje = 0;
            var zsl = 0;
            if (dtGridtab4 != null && dtGridtab4.Rows.Count > 0)
                for (var i = 0; i < dtGridtab4.Rows.Count; i++)
                {
                    zje += Convert.ToDouble(dtGridtab4.Rows[i]["N_TKJE"]);
                    zsl += Convert.ToInt32(dtGridtab4.Rows[i]["I_TKSL"]);
                }

            lbZongYeStab4.Text = "共" + dtGridtab4.Rows.Count + "条";
            txtTuiKuanHJtab4.Text = zje.ToString();
            txtTuiKuanSLHJtab4.Text = zsl.ToString();
        }

        /// <summary>
        ///     加载tab5页签数据 欠费调整
        /// </summary>
        private void LoadGridDataTab5()
        {
            //string hxje = null, lhbh = null;
            //if (rbnHeXiaoJEtab5.Checked && cbmHeXiaoJEtab5.Text != "" && txtHeXiaoJEtab5.Text != "")
            //{
            //    hxje = txtHeXiaoJEtab5.Text;
            //}
            //else if (rbnLaiHanBHtab5.Checked && txtLaiHanBHtab5.Text != "")
            //{
            //    lhbh = txtLaiHanBHtab5.Text;
            //}
            //this.dtGridtab5 = _SpHelper.P_YSCX_JIHUABG(v_zwy == -1 ? null : (int?)v_zwy,
            //                                              v_zwm == -1 ? null : (int?)v_zwm,
            //                                              v_zhandian,
            //                                              v_guanlikuai,
            //                                              v_ywy == null ? null : (int?)Convert.ToInt32(v_ywy),
            //                                              this.cmbShuiLiangYM1.Text,
            //                                              !this.rbnShuiLiangYM.Checked ? null : (int?)Convert.ToInt32(this.txtShuiLiangYM2.Text),
            //                                              !this.rbnYongHuH.Checked ? null : this.txtYongHuH.Text,
            //                                              !this.rbnYongHuM.Checked ? null : this.txtYongHuM.Text,
            //                                              this.cbmHeXiaoJEtab5.Text,
            //                                              hxje == null ? null : (decimal?)Convert.ToDecimal(hxje),
            //                                              lhbh
            //    ).Tables[0];
            //this.gvGridtab5.DataSource = this.dtGridtab5;
            //this.gvGridtab5.DataBind();
            //decimal jineSum = 0;
            //for (int i = 0; i < this.dtGridtab5.Rows.Count; i++)
            //{
            //    jineSum = jineSum + Convert.ToDecimal(this.dtGridtab5.Rows[i]["N_HEXIAOJE"]);
            //}
            // this.txtHeXiaoJEHZtab5.Text = jineSum.ToString("0.00");
        }

        /// <summary>
        ///     加载tab6页签数据 多收
        /// </summary>
        private void LoadGridDataTab6(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var v_je = rabJinETab6.Checked && cmbJinE2Tab6.Text != "" && txtJinETab6.Text != ""
                ? cmbJinE2Tab6.Text + txtJinETab6.Text
                : null;
            dtGridtab6 = SearchSpHelper.P_QSCX_ZWCX_DUOSHOU(BusinessTool.WType, v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh,
                v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym, v_je).Tables[0];
            gvGridtab6.DataSource = dtGridtab6;
            gvGridtab6.DataBind();
            decimal jineSum = 0;
            for (var i = 0; i < dtGridtab6.Rows.Count; i++)
                jineSum = jineSum + Convert.ToDecimal(dtGridtab6.Rows[i]["DS"]);
            txtDuoShouJEHZtab6.Text = jineSum.ToString("0.00");
        }

        /// <summary>
        ///     加载tab7页签数据 退回灌费
        /// </summary>
        private void LoadGridDataTab7(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            //gvGridtab7.DataSource = dtGridtab7;// ds.Tables[0];
            //gvGridtab7.DataBind();
            //lbZongBiStab7.Text = "共" + pagecount + "笔";
        }

        /// <summary>
        ///     加载tab8页签数据 水资源费
        /// </summary>
        private void LoadGridDataTab8(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm, string v_ym)
        {
            var v_je = rabJinETab8.Checked && cmbJinE2Tab8.Text != "" && txtJinETab8.Text != ""
                ? cmbJinE2Tab8.Text + txtJinETab8.Text
                : null;
            var v_szysj = rabShuiZiYFTab8.Checked && cmbShuiZiYFTab8.Text != "" && txtShuiZiYFTab8.Text != ""
                ? cmbShuiZiYFTab8.Text + txtShuiZiYFTab8.Text
                : null;
            dtGridtab8 = SearchSpHelper.P_QSCX_ZWCX_SHUIZIYF(BusinessTool.WType, v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh,
                v_yhm, v_qsyt, v_hylx, v_zgbm, v_ym, v_je, v_szysj).Tables[0];
            gvGridtab8.DataSource = dtGridtab8;
            gvGridtab8.DataBind();
            double zje = 0;
            if (dtGridtab8 != null && dtGridtab8.Rows.Count > 0)
                for (var i = 0; i < dtGridtab8.Rows.Count; i++)
                    zje += Convert.ToDouble(dtGridtab8.Rows[i]["N_SHUIZIYF"]);
            lbZongYeStab8.Text = "共" + dtGridtab8.Rows.Count + "条";
            txtHeXiaoJEtab8.Text = zje.ToString();
        }

        /// <summary>
        ///     加载tab9页签数据 补收
        /// </summary>
        private void LoadGridDataTab9(int v_zwy, int v_zwm, int v_hnhw, string v_xzq, string v_yhh, string v_yhm,
            string v_qsyt, string v_hylx, string v_zgbm)
        {
            var v_bsje = rabJinETab9.Checked && cmbJinE2Tab9.Text != "" && txtJinETab9.Text != ""
                ? cmbJinE2Tab9.Text + txtJinETab9.Text
                : null;
            dtGridtab9 = _SpHelper.P_QSCX_ZWCX_BUSHOU(BusinessTool.WType, v_zwy, v_zwm, v_hnhw, v_xzq, v_yhh, v_yhm,
                v_qsyt, v_hylx, v_zgbm, v_bsje).Tables[0];
            gvGridtab9.DataSource = dtGridtab9;
            gvGridtab9.DataBind();
            double zje = 0;
            if (dtGridtab9 != null && dtGridtab9.Rows.Count > 0)
                for (var i = 0; i < dtGridtab9.Rows.Count; i++)
                    zje += Convert.ToDouble(dtGridtab9.Rows[i]["N_JINE"]);
            lbZongYeStab9.Text = "共" + dtGridtab9.Rows.Count + "条";
            txtJEtab9.Text = zje.ToString();
        }

        protected void ASPxCallbackControl_Callback(object source, CallbackEventArgs e)
        {
        }

        #endregion
    }
}